<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>优惠券编辑--${site.name}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="${site.description}"/>
    <meta name="keywords" content="${site.keywords}"/>
    <meta name="author" content="${site.author}"/>
    <link rel="icon" href="${site.logo}">
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css" media="all" />
    <style type="text/css">
        .layui-form-item .layui-inline{ width:33.333%; float:left; margin-right:0; }
        @media(max-width:1240px){
            .layui-form-item .layui-inline{ width:100%; float:none; }
        }
        .layui-form-item .role-box {
            position: relative;
        }
        .layui-form-item .role-box .jq-role-inline {
            height: 100%;
            overflow: auto;
        }

    </style>
</head>
<body class="childrenBody">
<form class="layui-form" >
    <input value="${mallCoupon.id}" name="id" type="hidden">
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  优惠券名称</label>
        <div class="layui-input-block">
                <input  type="text" class="layui-input" value = "${mallCoupon.name}" name="name" lay-verify="required" placeholder="请输入优惠券名称">

        </div>
    </div>
     <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  面额</label>
        <div class="layui-input-inline">
            <input  type="text"  class="layui-input" name="price" lay-verify="required" placeholder="请输入面额"  value = "${mallCoupon.price}" >
        </div>
        <div class="layui-form-mid layui-word-aux">元</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  满多少可用</label>
        <div class="layui-input-inline">
            <input  type="text"  class="layui-input" name="man" lay-verify="required" placeholder="请输入满多少可用"  value = "${mallCoupon.man}" >
        </div>
        <div class="layui-form-mid layui-word-aux">元可用</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  发放数量</label>
        <div class="layui-input-block">

            <input  type="text"  class="layui-input" name="num" lay-verify="required" placeholder="请输入发放数量"  value = "${mallCoupon.num}" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  开始领取时间</label>
        <div class="layui-input-block">
			<input type="text" class="layui-input" id="startTime" name="startTime"  lay-verify="required"
					readonly="readonly" placeholder="选择开始领取时间"  value = "${mallCoupon.startTime?string('yyyy-MM-dd hh:mm')}" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  结束领取时间</label>
        <div class="layui-input-block">
			<input type="text" class="layui-input" id="endTime" name="endTime"  lay-verify="required"
					readonly="readonly" placeholder="选择结束领取时间" value = "${mallCoupon.endTime?string('yyyy-MM-dd hh:mm')}" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> <span class="required">*</span>  使用结束时间</label>
        <div class="layui-input-block">
			<input type="text" class="layui-input" id="invalidEndTime" name="invalidEndTime"  lay-verify="required"
					readonly="readonly" placeholder="选择使用结束时间" value = "${mallCoupon.invalidEndTime?string('yyyy-MM-dd hh:mm')}" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addMallCoupon">立即提交</button>
             <button class="layui-btn layui-btn-primary" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name)); ">关闭</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer','laydate' ],function(){
        var form      = layui.form,
                $     = layui.jquery,
                layer = layui.layer,laydate = layui.laydate;

        laydate.render({
		    elem: '#startTime'
		    ,type: 'datetime'
		    ,format: 'yyyy-MM-dd HH:mm'
		  });
		laydate.render({
		    elem: '#endTime'
		    ,type: 'datetime'
		    ,format: 'yyyy-MM-dd HH:mm'
		  });
		laydate.render({
		    elem: '#invalidEndTime'
		    ,type: 'datetime'
		    ,format: 'yyyy-MM-dd HH:mm'
		  });

        form.on("submit(addMallCoupon)",function(data){
            var loadIndex = layer.load(2, {
                shade: [0.3, '#333']
            });
            data.field.startTime = new Date(data.field.startTime);
			data.field.endTime = new Date(data.field.endTime);
			data.field.invalidEndTime = new Date(data.field.invalidEndTime);
            //给角色赋值
            $.post("${base}${adminPrefix}/mall-coupon/edit",data.field,function(res){
                layer.close(loadIndex);
                if(res.success){
                    parent.layer.msg("编辑成功！",{time:1000},function(){
                        parent.layer.close(parent.editIndex);
                        //刷新父页面
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.message);
                }
            });
            return false;
        });

    });
</script>
</body>
</html>